/*
 * This file is part of Sparwe.
 *
 *  Sparwe is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Sparwe is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Sparwe.  If not, see <http://www.gnu.org/licenses/>.
 */ 


#ifndef __EVENTMANAGER_H__
#define __EVENTMANAGER_H__

#include <SFML/Window.hpp>
#include <boost/thread.hpp>
#include <boost/bind.hpp>

#include "queue.h"

namespace sp_core
{
	class Device;

	/** 
	 * @brief 
	 */
	class EventManager
	{
		public:
			/** 
			 * @brief Initializes the event manager.
			 * 
			 * @param window 
			 */
			EventManager(sf::Window* window);

			/** 
			 * @brief Crush, kill 'n destroy! \m/ (-_-) \m/
			 */
			virtual ~EventManager();

			/** 
			 * @brief Starts the event management thread.
			 */
			void Start();
			/** 
			 * @brief Stops the event management thread.
			 */
			void Stop();

			/** 
			 * @brief Adds a new event to the event queue.
			 * 
			 * @param event 
			 */
			void PushEvent(sf::Event* event);

		private:
			
			/** 
			 * @brief Event loop...
			 */
			void Loop();

			Queue<sf::Event*> mEventQueue;
			sf::Window* mpWindow;
			boost::thread* mpManagerThread;
	};
}



#endif
